package com.bruce.pattern.behavioral.memento;

import lombok.Getter;
import lombok.Setter;

/**
 * Created by bruce on 2018/11/10 21:25
 */
@Setter
@Getter
public class Article {

    private String title;

    private String content;

    private String imgs;

    public ArticleMemento saveToMemento() {
        return new ArticleMemento(title, content, imgs);
    }

    public void undoFromMemento(ArticleMemento memento) {
        this.title = memento.getTitle();
        this.content = memento.getContent();
        this.imgs = memento.getImgs();
    }

    @Override
    public String toString() {
        return "Article{" +
                "title='" + title + '\'' +
                ", content='" + content + '\'' +
                ", imgs='" + imgs + '\'' +
                '}';
    }
}
